home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
001
/
gt13001.arc
/
TIMER.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1987-06-18
|
2KB
|
99 lines
PROGRAM
timer;
TYPE
STRING10 = STRING[10];
registerset = RECORD
AX,BX,CX,DX,BP,SI,DI,DS,ES,Flags : INTEGER;
END;
VAR
regs : registerset;
(****************************************************************************)
(* TIME SERVICE ROUTINES *)
(****************************************************************************)
PROCEDURE
real_time( VAR t : REAL );
BEGIN
WITH regs DO BEGIN
AX := $2C00;
msdos(regs);
t := (int(hi(CX)) * 360000.0)
+ (int(lo(CX)) * 6000.0)
+ (int(hi(DX)) * 100.0)
+ int(lo(DX));
END;
END;
FUNCTION
Elapsed(VAR start : REAL) : REAL;
VAR
curr : REAL;
BEGIN
real_time(curr);
WHILE (curr < start) DO
curr:=curr + 4320000.0;
Elapsed:=curr - start;
END;
VAR
xp : INTEGER;
x,x0,x1 : INTEGER;
y,y0,y1 : REAL;
exit_loop : BOOLEAN;
target : REAL;
FUNCTION
fx(d : INTEGER) : REAL;
VAR
rs,te : REAL;
j,k : INTEGER;
BEGIN
write('.');
te:=target*10.0;
real_time(rs);
FOR j:=1 TO trunc(te) DO
FOR k:=1 TO d DO;
fx:=Elapsed(rs);
END;
BEGIN
ClrScr;
Writeln('Time Base Calculator. By: P & M Software Co.');
writeln;
Writeln('This program determines the correct setting for the "Millisec Loop Count"');
Writeln('for your computer. It will take a few minutes to run, so be patient...');
writeln;
Write('WORKING');
x1:=37;
target:=200.0;
REPEAT
x1:=(x1*2);
y1:=fx(x1);
UNTIL (y1 > target);
x0:=(x1 div 2);
exit_loop:=FALSE;
writeln;
write('.');
x:=0;
REPEAT
xp:=x;
x:=((x1+x0) div 2);
writeln(x0,' - ',x,' - ',x1);
IF (x = xp) THEN
exit_loop:=TRUE
ELSE BEGIN
y:=fx(x);
IF (y > target) THEN
x1:=x
ELSE
x0:=x;
END;
UNTIL (exit_loop);
writeln;
x:=((x1+x0+1) div 2);
writeln('The correct value for the "Millisec Loop Count" is: ',x);
writeln;
END.